package com.mikepenz.presenter.imp;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;

import com.mikepenz.app.activity.OrderActivity;
import com.mikepenz.bean.CarBean;
import com.mikepenz.presenter.ProductPresenter;
import com.mikepenz.view.ProductView;

/**
 * Created by Administrator on 2015/9/21.
 */
public class ProductPresenterImp implements ProductPresenter {

    Context c;
    CarBean carBean;
    String phone;
    ProductView view;

    public ProductPresenterImp(Activity c){
        this(c, (ProductView) c);
    }

    public ProductPresenterImp(Activity c,ProductView view){
        this.c = c;
        this.view = view;
        carBean = (CarBean) c.getIntent().getExtras().getSerializable("car");
        phone = c.getIntent().getExtras().getString("phone");
    }

    @Override
    public void OnOrderClick() {
        Intent intent = new Intent(c, OrderActivity.class);
        Bundle bundle = new Bundle();
        bundle.putSerializable("car",carBean);
        intent.putExtras(bundle);
        c.startActivity(intent);
    }

    @Override
    public void OnSentClick() {
        Intent intent = new Intent(c, OrderActivity.class);
        Bundle bundle = new Bundle();
        bundle.putSerializable("car",carBean);
        intent.putExtras(bundle);
        c.startActivity(intent);
    }

    @Override
    public void OnPhoneClick() {
        Uri uri = Uri.parse("tel:"+phone);
        Intent intent = new Intent(Intent.ACTION_DIAL, uri);
        c.startActivity(intent);
    }

    @Override
    public void assignment() {
        view.assignment(carBean);
    }
}
